import { reactive } from 'vue'
import * as echarts from 'echarts'
var seriesData = [{
    name: "进行中",
    value: "40000"
}, {
    name: "等待中",
    value: "40000"
}, {
    name: "已完成",
    value: "53000"
}, {
    name: "失败",
    value: "40000"
}];
var legendData = ["进行中", "等待中", "已完成", "失败"]
var colorList = ['#73DDFF', '#73ACFF', '#FDD56A', '#FDB36A', '#FD866A', '#9E87FF', '#58D5FF', "#f12345"];
var chartObj = {
    xAxisData: ['用户1', '用户2', '用户3', '用户4', '用户5', '用户6'],
    legendData: ['投诉量','解决量','投诉解决率'],
    title: "多纵向堆积图折线图",
    serieData: [],
    metaDate: [
        [120, 140, 100, 120, 300, 230],
        [200, 120, 300, 200, 170, 300],
        [100,200, 140, 300, 200, 180]
    ],
}
for(var v=0; v < chartObj.legendData.length ; v++){
    var serie = {
        name:legendData[v],
        type: 'bar',
        stack:"circle",
        symbolSize:10,
        data: chartObj.metaDate[v]
    };
    chartObj.serieData.push(serie)
    var colors = ["#036BC8","#4A95FF","#5EBEFC","#2EF7F3","#FFFFFF"];
}
export default function () {
    const taskOption= reactive({
        title: {
            text: '状态',
            x: 'center',
            y: 'center',
            textStyle: {
                color: '#fff'
            }
        },
        tooltip: {
            trigger: 'item',
            borderColor: 'rgba(255,255,255,.3)',
            backgroundColor: 'rgba(13,5,30, 1)',
            borderWidth: 1,
            padding: 5,
            textStyle: {
                color: '#fff'
            },
            formatter: function(parms) {
                var str = parms.marker + "" + parms.data.name + "</br>" +
                    "数量：" + parms.data.value + "头</br>" +
                    "占比：" + parms.percent + "%";
                return str;
            }
        },
        legend: {
            type: "scroll",
            orient: 'vertical',
            left: 'left',
            align: 'auto',
            top: 'middle',
            textStyle: {
                color: '#fff'
            },
            data: legendData
        },
        series: [{
            type: 'pie',
            z: 3,
            center: ['50%', '50%'],
            radius: ['25%', '45%'],
            clockwise: true,
            avoidLabelOverlap: true,
            hoverOffset: 15,
            itemStyle: {
                normal: {
                    color: function(params) {
                        return colorList[params.dataIndex]
                    }
                }
            },
            label: {
                show: true,
                position: 'outside',
                formatter: '{a|{b}：{d}%}\n{hr|}',
                rich: {
                    hr: {
                        backgroundColor: 't',
                        borderRadius: 3,
                        width: 3,
                        height: 3,
                        padding: [3, 3, 0, -12]
                    },
                    a: {
                        padding: [-30, 15, -20, 15]
                    }
                }
            },
            labelLine: {
                normal: {
                    length: 20,
                    length2: 30,
                    lineStyle: {
                        width: 1
                    }
                }
            },
            data: seriesData
        }, {
            name:'第一层环',
            type: 'pie',
            z: 2,
            tooltip:{
                show:false
            },
            center: ['50%', '50%'],
            radius: ['45%', '58%'],
            hoverAnimation: false,
            clockWise: false,
            itemStyle: {
                normal: {
                    // shadowBlur: 40,
                    // shadowColor: 'rgba(0, 255, 255,.3)',
                    color: 'rgba(1,15,80,.4)',
                },
                emphasis:{
                    color: 'rgba(1,15,80,.4)',
                }
            },
            label: {
                show: false
            },
            data: [100]
        }, {
            name:'第二层环',
            type: 'pie',
            z: 1,
            tooltip:{
                show:false
            },
            center: ['50%', '50%'],
            radius: ['58%', '76%'],
            hoverAnimation: false,
            clockWise: false,
            itemStyle: {
                normal: {
                    // shadowBlur: 40,
                    // shadowColor: 'rgba(0, 255, 255,.3)',
                    color: 'rgba(0,15,69,.2)',
                },
                emphasis:{
                    color: 'rgba(0,15,69,.2)',
                }
            },
            label: {
                show: false
            },
            data: [100]
        }]
    })
    const monitorGPUOption = reactive({
        tooltip: {
            show: true,
            trigger: 'axis',
        },
        xAxis: {
            type: 'category',
            boundaryGap: false,
            data: [] as string[],
            axisLine: {
                lineStyle: {
                    // color: '#434343',
                    color: '#858585',
                },
            },
            axisLabel: {
                fontSize: 14,
            }
        },
        grid: {
            right: '5%',
            left: '5%',
            bottom: '20px',
            top: '5%',
        },
        yAxis: {
            type: 'value',
            show: true,
            axisLine: {
                show: false,
                lineStyle: {
                    // color: '#434343',
                    color: '#858585',
                },
            },
            splitLine: {
                lineStyle: {
                    color: '#434343',
                    opacity: 0.3,
                },
            },
            axisLabel: {
                formatter: function (val: string | number) {
                    return val + '%'
                },
                fontSize: 14,

            },
            min: 0,
            max: 100,
        },
        series: {
            name: 'GPU使用率',
            type: 'line',
            data: [] as number[],
            symbol: 'none',
            lineStyle: {
                width: 1,
                type: 'solid',
                color: '#30B1BA',
            },
            areaStyle: {
                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                    {
                        offset: 1,
                        color: '#00000000',
                    },
                    {
                        offset: 0,
                        color: '#30B1BA',
                    },
                ]),
            },
        },
    })
    const monitorNetworkOption = reactive({
        tooltip: {
            show: true,
            trigger: 'axis',
        },
        xAxis: {
            type: 'category',
            boundaryGap: false,
            data: [] as string[],
            axisLine: {
                lineStyle: {
                    // color: '#434343',
                    color: '#858585',
                },
            },
        },
        grid: {
            right: '5%',
            left: '5%',
            bottom: '20px',
            top: '5%',
        },
        yAxis: {
            type: 'value',
            show: true,
            axisLine: {
                show: false,
                lineStyle: {
                    color: '#858585',
                    // color: '#434343',
                },
            },
            splitLine: {
                lineStyle: {
                    color: '#434343',
                    opacity: 0.3,
                },
            },
            axisLabel: {
                formatter: function (val: string | number) {
                    return val + '%'
                },
                fontSize: 14,
            },
        },
        series: {
            name: '使用率',
            type: 'line',
            data: [] as number[],

            symbol: 'none',
            lineStyle: {
                width: 1,
                type: 'solid',
                color: '#38FF06',
            },
            areaStyle: {
                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                    {
                        offset: 1,
                        color: '#00000000',
                    },
                    {
                        offset: 0,
                        color: '#38FF06',
                    },
                ]),
            },
        },
    })
    const monitorMemoryOption = reactive({
        tooltip: {
            show: true,
            trigger: 'axis',
        },
        xAxis: {
            type: 'category',
            boundaryGap: false,
            data: [] as string[],
            axisLine: {
                lineStyle: {
                    // color: '#434343',
                    color: '#858585',
                },
            },
            axisLabel: {
                fontSize: 14,
            }
        },
        grid: {
            right: '5%',
            left: '5%',
            bottom: '20px',
            top: '5%',
        },
        yAxis: {
            type: 'value',
            show: true,
            axisLine: {
                show: false,
                lineStyle: {
                    color: '#858585',
                    // color: '#434343',
                },
            },
            splitLine: {
                lineStyle: {
                    color: '#434343',
                    opacity: 0.3,
                },
            },
            axisLabel: {
                formatter: function (val: string | number) {
                    return val + '%'
                },
                fontSize: 14,
            },
            min: 0,
            max: 100,
        },
        series: {
            name: '使用率',
            type: 'line',
            data: [] as number[],

            symbol: 'none',
            lineStyle: {
                width: 1,
                type: 'solid',
                color: '#38FF06',
            },
            areaStyle: {
                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                    {
                        offset: 1,
                        // color: '#434343',
                        color: '#00000000',
                    },
                    // {
                    //     offset: 0.5,
                    //     // color: '#434343',
                    //     color: '#38ff06d0',
                    // },
                    {
                        offset: 0,
                        color: '#38FF06',
                    },
                ]),
            },
        },
    })
    const monitorDiskOption = reactive({
        tooltip: {
            show: true,
            trigger: 'axis',
        },
        xAxis: {
            type: 'category',
            boundaryGap: false,
            data: [] as string[],
            axisLine: {
                lineStyle: {
                    // color: '#434343',
                    color: '#858585',
                },
            },
            axisLabel: {
                fontSize: 14,
            }
        },
        grid: {
            right: '5%',
            left: '5%',
            bottom: '20px',
            top: '5%',
        },
        yAxis: {
            type: 'value',
            show: true,
            axisLine: {
                show: false,
                lineStyle: {
                    color: '#858585',
                    // color: '#434343',
                },
            },
            splitLine: {
                lineStyle: {
                    color: '#434343',
                    opacity: 0.3,
                },
            },
            axisLabel: {
                formatter: function (val: string | number) {
                    return val + '%'
                },
                fontSize: 14,
            },
            min: 0,
            max: 100,
        },
        series: {
            name: '使用率',
            type: 'line',
            data: [] as number[],

            symbol: 'none',
            lineStyle: {
                width: 1,
                type: 'solid',
                color: '#5cdbd3',
            },
            areaStyle: {
                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                    {
                        offset: 1,
                        color: '#00000000',
                    },
                    {
                        offset: 0,
                        color: '#5cdbd3',
                    },
                ]),
            },
        },
    })
    function getOption(chartObj) {
        let option = {
            title : {text: chartObj.title,textAlign:'left',textStyle:{color:"#fff",fontSize:"16",fontWeight:"normal"}},
            legend: {
                show:true,left:"right",data:chartObj.legendData,y:"0%",
                itemWidth:18,itemHeight:12,textStyle:{color:"#fff",fontSize:14},
            },
            color:['#5179ff', '#18c2bc', '#33b4ff', '#fda124', '#ff4b55', '#68d568'],
            grid: {left: '2%',top:"10%",bottom: 5,right:10,containLabel: true},
            tooltip : { trigger: 'axis',axisPointer : { type : 'shadow'}},
            xAxis: [
                {
                    type: 'category',
                    axisLine: { show: true,lineStyle:{ color:'#6173A3' }},
                    axisLabel:{interval:0,textStyle:{color:'#9ea7c4',fontSize:14} },
                    axisTick : {show: false},
                    data:chartObj.xAxisData,
                },
            ],
            yAxis: [
                {
                    axisTick : {show: false},
                    splitLine: {show:false},
                    axisLabel:{textStyle:{color:'#9ea7c4',fontSize:14} },
                    axisLine: { show: true,lineStyle:{ color:'#6173A3'}},
                },
            ],
            series:chartObj.serieData
        }
        return option
    }
    function getOptionIndex(chartObj) {
        let option = {
            title : {text: chartObj.title,textAlign:'left',textStyle:{color:"#fff",fontSize:"16",fontWeight:"normal"}},
            legend: {
                show:true,left:"right",data:chartObj.legendData,y:"0%",
                itemWidth:18,itemHeight:12,textStyle:{color:"#fff",fontSize:14},
            },
            color:['#5179ff', '#18c2bc', '#33b4ff', '#fda124', '#ff4b55', '#68d568'],
            grid: {left: '2%',top:"10%",bottom: 5,right:10,containLabel: true},
            tooltip : { trigger: 'axis',axisPointer : { type : 'shadow'}},
            xAxis: [
                {
                    type: 'category',
                    axisLine: { show: true,lineStyle:{ color:'#6173A3' }},
                    axisLabel:{interval:0, rotate: 45, textStyle:{color:'#9ea7c4',fontSize:14} },
                    axisTick : {show: false},
                    data:chartObj.xAxisData,
                },
            ],
            yAxis: [
                {
                    axisTick : {show: false},
                    splitLine: {show:false},
                    axisLabel:{textStyle:{color:'#9ea7c4',fontSize:14} },
                    axisLine: { show: true,lineStyle:{ color:'#6173A3'}},
                },
            ],
            series:chartObj.serieData
        }
        return option
    }
    function getRightOption(dataList, lengthDataList) {
        let options = {
            title: {
                text: '类型',
                x: 'center',
                y: 'center',
                textStyle: {
                    color: '#fff'
                }
            },
            tooltip: {
                trigger: 'item',
                borderColor: 'rgba(255,255,255,.3)',
                backgroundColor: 'rgba(13,5,30, 1)',
                borderWidth: 1,
                padding: 5,
                textStyle: {
                    color: '#fff'
                },
                formatter: function(parms) {
                    var str = parms.marker + "" + parms.data.name + "</br>" +
                        "类型数量：" + parms.data.value + "个</br>" +
                        "占比：" + parms.percent + "%";
                    return str;
                }
            },
            legend: {
                type: "scroll",
                orient: 'vertical',
                left: 'left',
                align: 'auto',
                top: 'middle',
                textStyle: {
                    color: '#fff'
                },
                data: lengthDataList
            },
            series: [{
                type: 'pie',
                z: 3,
                center: ['50%', '50%'],
                radius: ['25%', '45%'],
                clockwise: true,
                avoidLabelOverlap: true,
                hoverOffset: 15,
                itemStyle: {
                    normal: {
                        color: function(params) {
                            return colorList[params.dataIndex]
                        }
                    }
                },
                label: {
                    show: true,
                    position: 'outside',
                    formatter: '{a|{b}：{d}%}\n{hr|}',
                    rich: {
                        hr: {
                            backgroundColor: 't',
                            borderRadius: 3,
                            width: 3,
                            height: 3,
                            padding: [3, 3, 0, -12]
                        },
                        a: {
                            padding: [-30, 15, -20, 15]
                        }
                    }
                },
                labelLine: {
                    normal: {
                        length: 20,
                        length2: 30,
                        lineStyle: {
                            width: 1
                        }
                    }
                },
                data: dataList
            }, {
                name:'第一层环',
                type: 'pie',
                z: 2,
                tooltip:{
                    show:false
                },
                center: ['50%', '50%'],
                radius: ['45%', '58%'],
                hoverAnimation: false,
                clockWise: false,
                itemStyle: {
                    normal: {
                        // shadowBlur: 40,
                        // shadowColor: 'rgba(0, 255, 255,.3)',
                        color: 'rgba(1,15,80,.4)',
                    },
                    emphasis:{
                        color: 'rgba(1,15,80,.4)',
                    }
                },
                label: {
                    show: false
                },
                data: [100]
            }, {
                name:'第二层环',
                type: 'pie',
                z: 1,
                tooltip:{
                    show:false
                },
                center: ['50%', '50%'],
                radius: ['58%', '76%'],
                hoverAnimation: false,
                clockWise: false,
                itemStyle: {
                    normal: {
                        // shadowBlur: 40,
                        // shadowColor: 'rgba(0, 255, 255,.3)',
                        color: 'rgba(0,15,69,.2)',
                    },
                    emphasis:{
                        color: 'rgba(0,15,69,.2)',
                    }
                },
                label: {
                    show: false
                },
                data: [100]
            }]
        }
        return options
    }
    const taskOptionLeft = reactive({
        title : {text: chartObj.title,textAlign:'left',textStyle:{color:"#fff",fontSize:"16",fontWeight:"normal"}},
        legend: {
            show:true,left:"right",data:legendData,y:"5%",
            itemWidth:18,itemHeight:12,textStyle:{color:"#fff",fontSize:14},
        },
        color:colors,
        grid: {left: '2%',top:"10%",bottom: 5,right:10,containLabel: true},
        tooltip : { trigger: 'axis',axisPointer : { type : 'shadow'}},
        xAxis: [
            {
                type: 'category',
                axisLine: { show: true,lineStyle:{ color:'#6173A3' }},
                axisLabel:{interval:0,textStyle:{color:'#9ea7c4',fontSize:14} },
                axisTick : {show: false},
                data:chartObj.xAxisData,
            },
        ],
        yAxis: [
            {
                axisTick : {show: false},
                splitLine: {show:false},
                axisLabel:{textStyle:{color:'#9ea7c4',fontSize:14} },
                axisLine: { show: true,lineStyle:{ color:'#6173A3'}},
            },
        ],
        series:chartObj.serieData
    })
    function getRecentWeekDates() {
        const today = new Date();  // 当前日期
        const dates = [];

        // 获取最近一周的日期，包括今天
        for (let i = 0; i < 7; i++) {
            const date = new Date(today);
            date.setDate(today.getDate() - i);

            const year = date.getFullYear();
            const month = String(date.getMonth() + 1).padStart(2, '0');
            const day = String(date.getDate()).padStart(2, '0');

            const formattedDate = `${year}-${month}-${day}`;
            dates.push(formattedDate);
        }

        return dates.reverse();  // 反转数组，使得日期从最旧到最新
    }
    const getChartLine = () => {
        let xLabel = getRecentWeekDates()
        let goToSchool = ["40", "60", "22", "85", "50", "40", "70"]
        let goOutSchool = ["20", "50", "12", "65", "30", "60"]
        let option = {
            tooltip: {
                trigger: 'axis',
                backgroundColor:'transparent',
                axisPointer: {
                    lineStyle: {
                        color: {
                            type: 'linear',
                            x: 0,
                            y: 0,
                            x2: 0,
                            y2: 1,
                            colorStops: [{
                                offset: 0,
                                color: 'rgba(126,199,255,0)' // 0% 处的颜色
                            }, {
                                offset: 0.5,
                                color: 'rgba(126,199,255,1)' // 100% 处的颜色
                            }, {
                                offset: 1,
                                color: 'rgba(126,199,255,0)' // 100% 处的颜色
                            }],
                            global: false // 缺省为 false
                        }
                    },
                },
                formatter: (p) => {
                    let dom = `<div style="width: 79px;
	height: 50px;;color:#fff;position: relative;">
        <svg style="position: absolute;top: 50%;
    left: 50%;
    transform: translateX(-50%) translateY(-50%);" class="svg" xmlns="http://www.w3.org/2000/svg" width="100" height="71" viewBox="0 0 84 55">
      <defs>
        <style>
          .cls-1 {
            fill: #07172c;
            fill-opacity: 0.8;
            stroke: #a7d8ff;
            stroke-linejoin: round;
            stroke-opacity: 0.2;
            stroke-width: 1px;
            fill-rule: evenodd;
          }

        </style>
      </defs>
      <path id="矩形_419" data-name="矩形 419" class="cls-1" d="M266,595h74v50H266V624.046L261,620l5-3.984V595Z"
        transform="translate(-258.5 -592.5)" />
    </svg>
        <div style="padding: 4px 8px 4px 14px;display: flex;
        justify-content: center;
        align-items: center;
        flex-direction: column;position: relative;z-index: 1;">
            <div style="margin-bottom: 4px;width:100%;display:${p[0]?'flex':'none'};justify-content:space-between;align-items:center;">
                <span style="font-size:14px;color:#7ec7ff;">${p[0]?p[0].seriesName:''}</span>
                <span style="font-size:14px;color:#fff;">${p[0]?p[0].data:''}</span>
            </div>
        </div>
    </div>`
                    return dom
                }
            },
            legend: {
                align: "left",
                right: '10%',
                top:'10%',
                type:'plain',
                textStyle:{
                    color:'#7ec7ff',
                    fontSize:16
                },
                // icon:'rect',
                itemGap:25,
                itemWidth:18,
                icon:'path://M0 2a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v0a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2z',

                data: []
            },
            grid: {
                top: '15%',
                left: '10%',
                right: '10%',
                bottom: '15%',
                // containLabel: true
            },
            xAxis: [{
                type: 'category',
                boundaryGap: false,
                axisLine: { //坐标轴轴线相关设置。数学上的x轴
                    show: true,
                    lineStyle: {
                        color: '#233653'
                    },
                },
                axisLabel: { //坐标轴刻度标签的相关设置
                    textStyle: {
                        color: '#7ec7ff',
                        padding: 16,
                        fontSize: 14
                    },
                    formatter: function(data) {
                        return data
                    }
                },
                splitLine: {
                    show: true,
                    lineStyle: {
                        color: '#192a44'
                    },
                },
                axisTick: {
                    show: false,
                },
                data: xLabel
            }],
            yAxis: [{
                name: '新增数量',
                nameTextStyle: {
                    color: "#7ec7ff",
                    fontSize: 16,
                    padding: 10
                },
                min: 0,
                splitLine: {
                    show: true,
                    lineStyle: {
                        color: '#192a44'
                    },
                },
                axisLine: {
                    show: true,
                    lineStyle: {
                        color: "#233653"
                    }

                },
                axisLabel: {
                    show: true,
                    textStyle: {
                        color: '#7ec7ff',
                        padding: 16
                    },
                    formatter: function(value) {
                        if (value === 0) {
                            return value
                        }
                        return value
                    }
                },
                axisTick: {
                    show: false,
                },
            }],
            series: [{
                name: '新增数量',
                type: 'line',
                symbol: 'circle', // 默认是空心圆（中间是白色的），改成实心圆
                showAllSymbol: true,
                symbolSize: 0,
                smooth: true,
                lineStyle: {
                    normal: {
                        width: 5,
                        color: "rgba(25,163,223,1)", // 线条颜色
                    },
                    borderColor: 'rgba(0,0,0,.4)',
                },
                itemStyle: {
                    color: "rgba(25,163,223,1)",
                    borderColor: "#646ace",
                    borderWidth: 2

                },
                tooltip: {
                    show: true
                },
                areaStyle: { //区域填充样式
                    normal: {
                        //线性渐变，前4个参数分别是x0,y0,x2,y2(范围0~1);相当于图形包围盒中的百分比。如果最后一个参数是‘true’，则该四个值是绝对像素位置。
                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                            offset: 0,
                            color: "rgba(25,163,223,.3)"


                        },
                            {
                                offset: 1,
                                color: "rgba(25,163,223, 0)"
                            }
                        ], false),
                        shadowColor: 'rgba(25,163,223, 0.5)', //阴影颜色
                        shadowBlur: 20 //shadowBlur设图形阴影的模糊大小。配合shadowColor,shadowOffsetX/Y, 设置图形的阴影效果。
                    }
                },
                data: goToSchool
            }]
        }
        return option
    }
    const getCy = () => {
// mock数据
        // mock数据
        let mockData = [
            {
                "doc_count": 170,
                "key": "俄乌冲突"
            },
            {
                "doc_count": 113,
                "key": "停机坪"
            },
            {
                "doc_count": 76,
                "key": "泽连斯基：与英国首相约翰逊讨论了最新战况"
            },
            {
                "doc_count": 31,
                "key": "约翰逊"
            },
            {
                "doc_count": 25,
                "key": "鲍里斯"
            },
            {
                "doc_count": 21,
                "key": "普京"
            },
            {
                "doc_count": 19,
                "key": "发射井"
            },
            {
                "doc_count": 15,
                "key": "Airbus Helicopters AS350 Ecureuil/Astar"
            },
            {
                "doc_count": 15,
                "key": "油库"
            },
            {
                "doc_count": 15,
                "key": "约翰"
            },
            {
                "doc_count": 14,
                "key": "2A65 MSTA-B"
            },
            {
                "doc_count": 12,
                "key": "空军公馆山营区"
            },
            {
                "doc_count": 9,
                "key": "泽联"
            },
            {
                "doc_count": 8,
                "key": "码头"
            },
            {
                "doc_count": 8,
                "key": "以色列"
            },
            {
                "doc_count": 7,
                "key": "泽连斯基"
            },
            {
                "doc_count": 7,
                "key": "第7近卫导弹师"
            },
            {
                "doc_count": 6,
                "key": "乌克兰克拉马托尔斯克"
            },
            {
                "doc_count": 6,
                "key": "国防部复兴岗营区"
            },
            {
                "doc_count": 6,
                "key": "泽联斯基"
            },
            {
                "doc_count": 6,
                "key": "第1129防空导弹团"
            },
            {
                "doc_count": 6,
                "key": "鲍里"
            },
            {
                "doc_count": 5,
                "key": "AeroVironment RQ-11 Raven"
            },
            {
                "doc_count": 5,
                "key": "乌克兰"
            },
            {
                "doc_count": 5,
                "key": "巴以冲突"
            },
            {
                "doc_count": 5,
                "key": "普"
            },
            {
                "doc_count": 5,
                "key": "鲍"
            },
            {
                "doc_count": 4,
                "key": "犹太"
            },
            {
                "doc_count": 4,
                "key": "美国"
            },
            {
                "doc_count": 4,
                "key": "油罐"
            },
            {
                "doc_count": 4,
                "key": "轨条砦"
            },
            {
                "doc_count": 4,
                "key": "岛屿"
            },
            {
                "doc_count": 4,
                "key": "ze"
            },
            {
                "doc_count": 4,
                "key": "中国办公政府"
            },
            {
                "doc_count": 4,
                "key": "台东机场"
            },
            {
                "doc_count": 4,
                "key": "台湾"
            },
            {
                "doc_count": 4,
                "key": "第20独立电子战营"
            },
            {
                "doc_count": 4,
                "key": "鲍里斯皮尔国际机场? Boryspil International Airport"
            },
            {
                "doc_count": 3,
                "key": "奥斯"
            },
            {
                "doc_count": 3,
                "key": "本轮巴以冲突已致加沙地带37765人死亡"
            },
            {
                "doc_count": 3,
                "key": "中国办公政府大楼"
            },
            {
                "doc_count": 3,
                "key": "乌克兰政府"
            },
            {
                "doc_count": 3,
                "key": "公馆山营区"
            },
            {
                "doc_count": 3,
                "key": "冯德莱恩"
            },
            {
                "doc_count": 3,
                "key": "第439近卫火箭炮旅"
            },
            {
                "doc_count": 2,
                "key": "112"
            },
            {
                "doc_count": 2,
                "key": "APS (Avtomat Podvodny Spetsialny)"
            },
            {
                "doc_count": 2,
                "key": "Admiral Panteleyev (548)"
            }
        ]

        // 随机颜色
        let randcolor = () => {
            let r = 100 + ~~(Math.random() * 100);
            let g = 135 + ~~(Math.random() * 100);
            let b = 100 + ~~(Math.random() * 100);
            return `rgb(${r}, ${g}, ${b})`
        }

        let option = {
            tooltip: {
                trigger: 'item',
                padding: [10, 15],
                textStyle: {
                    fontSize: 20
                },
                formatter: params => {
                    const { name, value } = params

                    return `
                    热搜词：${name} <br/>
                    数量：${value}
                `
                }
            },
            series: [{
                type: 'wordCloud',
                gridSize: 20,
                sizeRange: [12, 50],
                rotationRange: [0, 0],
                shape: 'circle',
                textStyle: {
                    normal: {
                        color: params => {
                            return randcolor()
                        }
                    },
                    emphasis: {
                        shadowBlur: 10,
                        shadowColor: '#333'
                    }
                },
                data: mockData.map(item => ({  // 映射数据并设置格式
                    name: item.key,
                    value: item.doc_count
                }))
            }]
        };
        return option
    }
    return {
        taskOption,
        monitorGPUOption,
        monitorNetworkOption,
        monitorDiskOption,
        monitorMemoryOption,
        taskOptionLeft,
        getOption,
        getOptionIndex,
        getRightOption,
        getChartLine,
        getCy
    }
}
